﻿using LNet;
using System;
using System.Collections.Generic;

namespace OestsCommon.Model
{
    public class Student : User
    {
        /// <summary>
        /// 是否在线  true 在线
        /// </summary>
        public bool OnLine { get; set; }
        public int ExamLog { get; set; }

        #region 实时状态属性

        /// <summary>
        /// 当前培训模式
        /// </summary>
        public PatternType CurrenPattern;

        /// <summary>
        /// 当前进行的任务
        /// </summary>
        [NonSerialized] public TaskModel CurrentTask;

        /// <summary>
        /// 当前进行的岗位
        /// </summary>
        [NonSerialized] public PostModel CurrentPost;

        /// <summary>
        /// 班级ID 列表，一个学生可以加入多个班级
        /// </summary>
        public List<int> ClassIds { get; set; }
        #endregion

        public Room _room;

        public Student()
        {
            Type = UserType.Student;
            ExamLog = 0;
        }


        public Student(string number, string pwd)
            : base(number, pwd)
        {
            Type = UserType.Student;
            ExamLog = 0;
        }
        public Student(User user)
        {
            DBid = user.DBid;
            Name = user.Name;
            Number = user.Number;
            Password = user.Password;
            Type = UserType.Student;
            ExamLog = 0;
        }



        /// <summary>
        /// 离开房间，
        /// </summary>
        public void LeaveRoom()
        {
            if (_room != null)
            {
                _room.DelMember(DBid);
                _room = null;
            }
        }


        public void BroadcastInRoomButMe(Response packet)
        {
            //for (int j = 0; j < _room.StudentTemps.Count; j++)
            //{
            //    ClientChannel client = ClientManager.Instance.GetStudentClientByStudentId(room.StudentTemps[j]);
            //    if (client != null)
            //    {
            //        if (client.User.DBid != clientMe.User.DBid)
            //        {
            //            client.Send(packet);
            //        }
            //    }
            //}
        }
    }
}
